<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
</head>
<body>
	<div class="container">
		<a class = "btn btn-success" href = "${pageContext.request.contextPath}/role/getAddUserPage.action">添加</a>
		<table class="table table-striped table-bordered table-hover table-condensed">
			<tr>
				<td>编号</td>
				<td>用户名</td>
				<td>密码</td>
				<td>邮箱</td>
				<td>年龄</td>
				<td>角色</td>
				<td>角色sn</td>
				<td>部门</td>
				<td>添加角色</td>
				<td>删除</td>
			</tr>
		<c:forEach items="${usersPageBean.list}" var="user">
			<tr>
				<td>${user.u_id}</td>
				<td>${user.u_name}</td>
				<td>${user.u_password}</td>
				<td>${user.u_email}</td>
				<td>${user.u_age}</td>
				<td>${user.r_name}</td>
				<td>${user.r_sn}</td>
				<td>${user.d_name}</td>
				<td><a href="${pageContext.request.contextPath}/role/toAddRole.action?id=${user.u_id}">添加角色</a></td>
				<td><a href="${pageContext.request.contextPath}/role/deleteById.action?id=${user.u_id}">删除</a></td>
			</tr>
		</c:forEach>
		</table>
		<nav aria-label="Page navigation">
		  <ul class="pagination">
		  <c:if test="${usersPageBean.pageNo == 1}">
		  	<li class="disabled">
		      <a href="#" aria-label="Previous">
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		  </c:if>
		  <c:if test="${usersPageBean.pageNo != 1}">
		  	<li>
		      <a href="${pageContext.request.contextPath}/role/pageList.action?pageNo=${usersPageBean.pageNo-1}&pageSize=3" aria-label="Previous">
		        <span aria-hidden="true">&laquo;</span>
		      </a>
		    </li>
		  </c:if>
		    <c:forEach begin="1" end="${usersPageBean.totalPage}" var="i">
		    	<c:if test="${i == usersPageBean.pageNo}">
		    		<li class="active"><a href="${pageContext.request.contextPath}/role/pageList.action?pageNo=${i}&pageSize=3">${i}</a></li>
		    	</c:if>		
		    	<c:if test="${i != usersPageBean.pageNo}">
		    		<li><a href="${pageContext.request.contextPath}/role/pageList.action?pageNo=${i}&pageSize=3">${i}</a></li>
		    	</c:if>		
		    </c:forEach>
		    <c:if test="${usersPageBean.pageNo == usersPageBean.totalPage}">
			    <li class="disabled">
			      <a href="#" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
		    </c:if>
		    <c:if test="${usersPageBean.pageNo != usersPageBean.totalPage}">
			    <li>
			      <a href="${pageContext.request.contextPath}/role/pageList.action?pageNo=${usersPageBean.pageNo+1}&pageSize=3" aria-label="Next">
			        <span aria-hidden="true">&raquo;</span>
			      </a>
			    </li>
		    </c:if>
		  </ul>
		</nav>
	</div>
</body>
</html>